/*
 * uart_it.c
 *
 *  Created on: May 26, 2025
 *      Author: lsy18
 */

#include "uart_it.h"
#include "usart.h"

#include "../Communicate/Uart_slave/uart_slave.h"
#include "../Hardware/Pos/pos.h"

#include "../Hardware/Led/led.h"

#include "stdio.h"

UART_IT_STRUCT slave_uart,pos_uart;

//int __io_putchar(int ch)
//{
//	HAL_UART_Transmit(&huart2, (uint8_t *) &ch , 1 , 1000);
//	return ch;
//}

void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
{
	if(huart == &huart_slave_it)
	{
		//HAL_GPIO_TogglePin(GPIOC, GPIO_PIN_13);
		slave_uart.receive_num++;
		slave_uart.uart_buff[slave_uart.receive_num-1] = slave_uart.uart_bit_buff;
		slave_exam();
	}
	else if(huart == &huart_pos)
	{
		pos_uart.receive_num++;
		pos_uart.uart_buff[pos_uart.receive_num-1] = pos_uart.uart_bit_buff;
		pos_exam();
	}
}

void uart_data_translocate(uint8_t *uart_buff , uint8_t star_location, uint8_t buff_num)
{
	for(uint8_t i=0; i<buff_num - 1; i++)
	{
		uart_buff[star_location+i] = uart_buff[star_location+i+1];
	}
}

